//
//  XDBMyCustomerHeader.m
//  xindailianmeng
//
//  Created by 张东 on 2017/2/17.
//  Copyright © 2017年 xindailianmeng.cn. All rights reserved.
//

#import "XDBMyCustomerHeader.h"

@interface XDBMyCustomerHeader ()
@property (weak, nonatomic) IBOutlet UILabel *sumCountLb;

@property (weak, nonatomic) IBOutlet UILabel *yesterdayCountLb;

@property (weak, nonatomic) IBOutlet UILabel *styleLb;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *realNameConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *ctimeConstraint;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mobileConstraint;
@end

@implementation XDBMyCustomerHeader

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"XDBMyCustomerHeader" owner:self options:nil].firstObject;
    }
    return self;
}

- (void)setCustomerDic:(NSDictionary *)CustomerDic {
    
    _CustomerDic = CustomerDic;
    
    NSString *sumCount = [NSString stringWithFormat:@"客户总数: %@人",CustomerDic[@"sumCount"]];
    
    NSMutableAttributedString *sumAttr = [[NSMutableAttributedString alloc] initWithString:sumCount];
    [sumAttr addAttribute:NSForegroundColorAttributeName value:kColorRGB(102,102,102) range:[sumCount rangeOfString:@"客户总数:"]];
    self.sumCountLb.attributedText = sumAttr;
    
    NSString *yesterdayCountStr = [NSString stringWithFormat:@"昨天新增: %@人",CustomerDic[@"yesterdayCount"]];
    
    NSMutableAttributedString *yesterdayAttr = [[NSMutableAttributedString alloc] initWithString:yesterdayCountStr];
    [yesterdayAttr addAttribute:NSForegroundColorAttributeName value:kColorRGB(102,102,102) range:[yesterdayCountStr rangeOfString:@"昨天新增:"]];
    self.yesterdayCountLb.attributedText = yesterdayAttr;
    
    
    self.styleLb.text = CustomerDic[@"style"];
    
}

- (void)layoutSubviews {
    
    self.frame = CGRectMake(0, 43, kScreenW, 96);
    
    self.realNameConstraint.constant = 57 * kscaleW;
    
    self.mobileConstraint.constant = 196 * kscaleW;
    
    self.ctimeConstraint.constant = 103 * kscaleW;
    
    [self updateConstraintsIfNeeded];
}

@end
